home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / docdemos / fordemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-09  |  513 b   |  20 lines

  1. program ForDemo;
  2. var
  3.   CharSet: set of Char;
  4.   c: Char;
  5.   n: Integer;
  6.   Fac: array [0 .. 10] of Integer;
  7.   PInt: ^Integer;
  8. begin
  9.    CharSet := ['g', 'p', 'c'];
  10.    for c in CharSet do
  11.      WriteLn (c);       { prints c g p in three lines }
  12.    Fac [0] := 1;
  13.    for n := 1 to 10 do  { computes the factorial of n for n = 0 .. 10 }
  14.      Fac [n] := Fac [n - 1] * n;
  15.    {$X+}
  16.    { prints n! for n = 0 .. 10 }
  17.    for PInt := @Fac [0] to @Fac [10] do
  18.      WriteLn (PInt - @Fac [0], '! = ', PInt^)
  19. end.
  20.